package com.mifan.common;/*
 * @Author Milan
 * @Date 2024/9/13 16:59
 */

import lombok.Data;

@Data
public class Results<T> {
    private int code;
    private String message;
    private T data;

    public Results() {
    }

    public Results(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    public static <T> Results<T> success(T data) {
        return new Results<>(0, "操作成功", data);
    }

    public static <T> Results<T> success(String message, T data) {
        return new Results<>(0, message, data);
    }

    public static <T> Results<T> failure(String message) {
        return new Results<>(1000, message, null);
    }

    public static <T> Results<T> failure(int code, String message) {
        return new Results<>(code, message, null);
    }

}